﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;


namespace NCKH.PersonalUser
{
    public partial class PersonalUser : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Name"] != null && Session["Name"] != "")
            {
                lblchao.Text = "Xin chào " + Session["Name"].ToString() + ",";
                lblten.Text = Session["Name"].ToString();
            }
            hienNgaytgia();
        }

        protected void lbntthoat_Click(object sender, EventArgs e)
        {
            Session["Name"] = "";
            Response.Redirect("/Trangchu.aspx");
        }

        protected void hienNgaytgia()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["NCKH"].ConnectionString;
            string sqlNgay = "Select Ngaytao From TAIKHOAN Where Tendangnhap='" + Session["Name"].ToString() + "'";
            using (SqlConnection Cnn = new SqlConnection(connectionString))
            {
                using (SqlCommand Cmd = new SqlCommand(sqlNgay, Cnn))
                {
                    Cmd.CommandType = CommandType.Text;
                    Cnn.Open();
                    using (SqlDataReader rd = Cmd.ExecuteReader())
                    {
                        if (rd.HasRows && rd.Read())
                        {
                            string ngay = rd["Ngaytao"].ToString();
                            // DateTime ngaytg = new DateTime();
                            // ngaytg=DateTime.ParseExact(ngay, "dd/mm/yyyy ", null);
                            lblngay.Text = String.Format("{0:dd/mm/yyyy}", ngay);

                            rd.Close();
                            Cnn.Close();
                        }

                    }
                }
            }
        }
        /*protected void ltbncanhan_Click(object sender, EventArgs e)
        {

        }*/

    }
}